home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Animation Wizard.dir / 00005_IncrDecrCast.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  1.8 KB  |  74 lines

  1. property iCastNumOffset, inPicts, ichPict, ichButton, iCurrentValue, iCastNumNormal, iCastNumIncr, iCastNumDecr
  2.  
  3. on birth me
  4.   return me
  5. end
  6.  
  7. on mInit me, castNumOffset, defaultVal, nPicts, chPict
  8.   set iCastNumOffset to castNumOffset
  9.   set inPicts to nPicts
  10.   set ichPict to chPict
  11.   set ichButton to ichPict + 1
  12.   mSetValue(me, defaultVal)
  13.   puppetSprite(ichPict, 1)
  14. end
  15.  
  16. on mHit me
  17.   set castNumNormal to the castNum of sprite ichButton
  18.   set iCastNumNormal to castNumNormal
  19.   set iCastNumIncr to castNumNormal + 1
  20.   set iCastNumDecr to castNumNormal + 2
  21.   set mouseDownFlag to 1
  22.   set firstTimeFlag to 1
  23.   repeat while mouseDownFlag
  24.     if rollOver(ichButton) then
  25.       if the mouseV <= the locV of sprite ichButton then
  26.         set the castNum of sprite ichButton to iCastNumIncr
  27.         set iCurrentValue to IncrMod(iCurrentValue, inPicts)
  28.       else
  29.         set the castNum of sprite ichButton to iCastNumDecr
  30.         set iCurrentValue to DecrMod(iCurrentValue, inPicts)
  31.       end if
  32.       mDraw(me)
  33.     else
  34.       set the castNum of sprite ichButton to castNumNormal
  35.       updateStage()
  36.     end if
  37.     if firstTimeFlag then
  38.       set firstTimeFlag to 0
  39.       wait(15)
  40.     end if
  41.     set mouseDownFlag to the mouseDown
  42.   end repeat
  43.   set the castNum of sprite ichButton to castNumNormal
  44.   updateStage()
  45.   return iCurrentValue
  46. end
  47.  
  48. on mGetValue me
  49.   return iCurrentValue
  50. end
  51.  
  52. on mGetCastNum me, index
  53.   return iCastNumOffset + index
  54. end
  55.  
  56. on mSetValue me, theNewValue
  57.   if (theNewValue < 1) or (theNewValue > inPicts) then
  58.     alert("Bad value passed to IncrDecrCast:" && theNewValue & RETURN & "Needs to be between 1 and " & inPicts)
  59.     return 
  60.   end if
  61.   set iCurrentValue to theNewValue
  62.   mDraw(me)
  63.   updateStage()
  64. end
  65.  
  66. on mDraw me
  67.   set the castNum of sprite ichPict to iCastNumOffset + iCurrentValue
  68.   updateStage()
  69. end
  70.  
  71. on mCleanUp me
  72.   puppetSprite(ichPict, 0)
  73. end
  74.